package dto

import (
	"time"
	"wxpay/internal/model"
	"wxpay/pkg/util"
)

type ProfitReturnDTO struct {
	// ID
	ID int64
	// 品牌id
	BrandID string
	// 商户分账单号
	OutOrderNo string
	// 二级商户商户号
	SubMchID string
	// 商户回退单号
	OutReturnNo string
	// 回退商户ID
	ReturnMchID string
	// 回退金额
	Amount int64
	// 回退描述
	Description string
	// 微信回退单号
	WxReturnNo string
	// 微信分账单id
	WxOrderID string
	// 服务商AppID
	AppID string
	// 服务商商户号
	MchID string
	// 创建时间
	CreateTime time.Time
	// 修改时间
	UpdateTime time.Time
}

func AdaptProfitReturn(info *ProfitReturnDTO) (r model.Profitreturn) {
	n := util.GetNow()
	r = model.Profitreturn{
		BrandID:     info.BrandID,
		MchID:       info.MchID,
		SubMchID:    info.SubMchID,
		AppID:       info.AppID,
		OutOrderNo:  info.OutOrderNo,
		OutReturnNo: info.OutReturnNo,
		WxOrderID:   info.WxOrderID,
		ReturnMchID: info.ReturnMchID,
		Amount:      info.Amount,
		Description: info.Description,
		WxReturnNo:  util.AdaptNullString(info.WxReturnNo),
		CreateTime:  n,
		UpdateTime:  n,
	}
	return
}

func ConvertProfitReturn(info *model.Profitreturn) (r *ProfitReturnDTO) {
	return &ProfitReturnDTO{
		ID:          info.ID,
		BrandID:     info.BrandID,
		OutOrderNo:  info.OutOrderNo,
		SubMchID:    info.SubMchID,
		OutReturnNo: info.OutReturnNo,
		ReturnMchID: info.ReturnMchID,
		Amount:      info.Amount,
		Description: info.Description,
		WxReturnNo:  util.ConvertNullString(info.WxReturnNo),
		WxOrderID:   info.WxOrderID,
		AppID:       info.AppID,
		MchID:       info.MchID,
		CreateTime:  info.CreateTime,
		UpdateTime:  info.UpdateTime,
	}
}
